<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let arr = [5, 1, 3, 7, 9, 1, 4, 8, 4, 5, 6, 114, 24, 8, 54, 84, 6, 456, 4, 79, 54, 78, 79, 7, 89, 98, 4]

        function quickSort(arr) {
            if (arr.length <= 1) {
                return arr;
            }

            let midIndex = Math.floor(arr.length / 2);
            let midIndexVal = arr.splice(midIndex,1);
            let left = [];
            let right = [];

            for(let i = 0;i<arr.length;i++){
                if(arr[i]<midIndexVal){
                    left.push(arr[i]);
                }else{
                    right.push(arr[i]);
                }
            }

            return quickSort(left).concat(midIndexVal,quickSort(right))

        }

        console.log(quickSort(arr));
    </script>
</body>

</html>